var tl;

  function onLoad() {
		var eventSource = new Timeline.DefaultEventSource();
		var zones = [
		];
		var zones2 = [
		];

		var theme = Timeline.ClassicTheme.create();
		theme.event.bubble.width = 350;
		theme.event.bubble.height = 300;

		/* Modification Info bulle */
		var default_fillInfo = Timeline.DefaultEventSource.Event.prototype.fillInfoBubble;
		Timeline.DefaultEventSource.Event.prototype.fillInfoBubble = function (elmt, theme, labeller) {
			var doc = elmt.ownerDocument;
			var title = this.getText();
			var link = this.getLink();
		     var image = this.getImage();

		     if (image != null) {
		         var img = doc.createElement("img");
		         img.src = image;

		         theme.event.bubble.imageStyler(img);
		         elmt.appendChild(img);
		     }

			var divTitle = doc.createElement("div");
			var textTitle = doc.createTextNode(title);
			if(link) {
				var a = doc.createElement("a");
				a.href = link;
				a.target = '_blank';
				a.appendChild(textTitle);
				divTitle.appendChild(a);
			} else {
				divTitle.appendChild(textTitle);
			}
			theme.event.bubble.titleStyler(divTitle);
			elmt.appendChild(divTitle);

			var divBody = doc.createElement("div");
			this.fillDescription(divBody);
			theme.event.bubble.bodyStyler(divBody);
			elmt.appendChild(divBody);

			var divTime = doc.createElement("div");
			this.fillTime(divTime,labeller);
			theme.event.bubble.timeStyler(divTime);
			elmt.appendChild(divTime);

			var divWiki = doc.createElement("div");
			this.fillWikiInfo(divWiki);
			theme.event.bubble.wikiStyler(divWiki);
			elmt.appendChild(divWiki);
		};

		/* Modification Date de départ */
		var date = "Dec 10 1934"


		var bandInfos = [
		    Timeline.createHotZoneBandInfo({
		        width:          "80%",
		        intervalUnit:   Timeline.DateTime.MONTH,
		        intervalPixels: 50,
		        zones:          zones,
		        eventSource:    eventSource,
		        date:           date,
		        timeZone:       +1,
		        theme:          theme
		    }),
		    Timeline.createHotZoneBandInfo({
		        width:          "20%",
		        intervalUnit:   Timeline.DateTime.YEAR,
		        intervalPixels: 200,
		        zones:          zones2,
		        eventSource:    eventSource,
		        date:           date,
		        timeZone:       +1,
		        overview:       true
		       // theme:          theme
		    })
		];

		// Infos sur les bandes
		bandInfos[1].syncWith = 0;
		bandInfos[1].highlight = true;
		for (var i = 0; i < bandInfos.length; i++) {
		    bandInfos[i].decorators = [
		        new Timeline.SpanHighlightDecorator({
		            startDate:  "Dec 10 1934",
		            endDate:    "Nov 02 1953",
		            color:      "#FAF0E6",
		            opacity:    50,
		            startLabel: "Début des Archives Bourbaki",
		            endLabel:   "Fin de l'étude",
		           // theme:      theme,
					cssClass: 't-highlight1'
		        }),
		    ];
		}

		tl = Timeline.create(document.getElementById("tl"), bandInfos, Timeline.HORIZONTAL);
		/* chargement fichier (éviter le cache du navigateur si données modifiées) */
		tl.loadXML("bourbaki.xml?"+ new Date().getTime(),
		/* tl.loadXML("bourbaki.xml",*/
		function(xml, url) { eventSource.loadXML(xml, url); }
		);
  }

function centerTimeline(year) {
    tl.getBand(0).setCenterVisibleDate(new Date(year, 0, 1));
}

var resizeTimerID = null;
function onResize() {
    if (resizeTimerID == null) {
        resizeTimerID = window.setTimeout(function() {
            resizeTimerID = null;
            tl.layout();
        }, 500);
    }
}
